Skip to content

perf(skip masks): skip masks as roaring bitmaps in fetch#421

Open
forshev wants to merge 1 commit into
mainfrom
420-skip-mask-as-roaring-bitmap
Open

perf(skip masks): skip masks as roaring bitmaps in fetch#421
forshev wants to merge 1 commit into
mainfrom
420-skip-mask-as-roaring-bitmap

Conversation

@forshev
Copy link
Copy Markdown
Collaborator

@forshev forshev commented May 6, 2026

Description

Read skip masks as roaring bitmap for fetch

Fixes #420


  • I have read and followed all requirements in CONTRIBUTING.md;
  • I used LLM/AI assistance to make this pull request;

If you have used LLM/AI assistance please provide model name and full prompt:

Model: {{model-name}}
Prompt: {{prompt}}

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 6, 2026

Codecov Report

❌ Patch coverage is 65.65657% with 34 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.60%. Comparing base (e0cf437) to head (ab18105).

Files with missing lines Patch % Lines
skipmaskmanager/loader.go 54.28% 11 Missing and 5 partials ⚠️
skipmaskmanager/encoding.go 58.33% 10 Missing ⚠️
skipmaskmanager/skip_mask_manager.go 76.19% 3 Missing and 2 partials ⚠️
skipmaskmanager/iterator_asc.go 83.33% 1 Missing ⚠️
skipmaskmanager/iterator_desc.go 83.33% 1 Missing ⚠️
skipmaskmanager/merged_iterator.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #421      +/-   ##
==========================================
- Coverage   70.65%   70.60%   -0.05%     
==========================================
  Files         219      219              
  Lines       16967    16998      +31     
==========================================
+ Hits        11988    12002      +14     
- Misses       4084     4096      +12     
- Partials      895      900       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@eguguchkin eguguchkin requested review from cheb0 and eguguchkin May 12, 2026 10:36
@forshev forshev force-pushed the 420-skip-mask-as-roaring-bitmap branch from 7d69985 to ab18105 Compare May 12, 2026 11:17
@eguguchkin eguguchkin added this to the v0.72.0 milestone May 18, 2026
return NewNMergedIterators(iterators), has, nil
}

// GetSkipMaskAsRoaringBitmap returns skip masks as roaring bitmap.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: comment name doesn't match function name

}

bitmap := roaring.New()
mu := &sync.Mutex{}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I can't say for sure whether using a mutex hurts performance and by how much, but I'd go with a non-blocking implementation here.
That is, I'd generate a separate bitmap in each goroutine and then merge them at the end.

Comment thread skipmaskmanager/loader.go
}
}

if err := l.release(); err != nil {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: We might exit the function on an error and never call release. In iterators, theoretically, we might also fail to reach release. For me, this is an open question: when is it better to close the file descriptor? Probably, it would be consistent to close the descriptor only when the faction is deleted — just like the index: we keep it open all the time. But that would require a more global refactoring. Alternatively, tie it to the lifetime of skipmaskmanager.loader, but then we would need to return its release() function together with the iterator.

diff --git a/frac/processor/search.go b/frac/processor/search.go
index 3c08eae0..53b2e906 100644
--- a/frac/processor/search.go
+++ b/frac/processor/search.go
@@ -95,7 +95,8 @@ func IndexSearch(
 	}
 
 	m = sw.Start("get_skip_lids")
-	skipLIDs, hasSkipLIDs, err := index.GetSkipLIDs(minLID, maxLID, params.Order.IsReverse())
+	skipLIDs, hasSkipLIDs, release, err := index.GetSkipLIDs(minLID, maxLID, params.Order.IsReverse())
+	defer release()
 	m.Stop()
 	if err != nil {
 		return nil, err

The comforting fact is that in Go, when an *os.File is garbage-collected, Close should be called (thanks to runtime.SetFinalizer), but this is not a reliable mechanism.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use roaring bitmaps to eval skip masks in fetch

4 participants